<template>
  <div>
    <div class="box" @click="$emit('choiceDog', list.dogName)">
      <img
        src="https://scpic.chinaz.net/files/pic/pic9/202003/zzpic23514.jpg"
        alt=""
      />
      <p @click.stop="changeColor" :style="{ backgroundColor: bgColor }">
        {{ list.dogName }}
      </p>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    list: {
      type: Object,
      required: true,
    },
  },
  data() {
    return {
      bgColor: "",
    };
  },
  methods: {
    changeColor() {
      this.bgColor = `rgb(${Math.floor(Math.random() * 256)},${Math.floor(
        Math.random() * 256
      )},${Math.floor(Math.random() * 256)})`;
    },
  },
};
</script>

<style scoped lang="less">
.box {
  width: 300px;
  border: 2px solid #ccc;
  text-align: center;
  float: left;

  img {
    width: 100%;
  }
}
</style>
